/*
 * Copyright 2012 Gayan Perera
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package gap.maven.script.components.spi;

import gap.maven.script.components.api.ExtractorPattern;

import java.io.File;
import java.io.IOException;

/**
 * Component interface which defines the api of the file extractor which can be used to extract archive files.
 * 
 * @author gayan
 */
public interface FileExtractor {
    
    /**
     * Extract the given archive file to the given directory. Only the files satisfies the given 
     * patterns will be extracted.
     * 
     * @param archive The archive file to be extracted.
     * @param toDir The directory to which the files are extracted to.
     * @param patterns Array of patterns to match, passing empty array cause all the files to be extracted.
     * @throws IOException
     */
    void extract(File archive, File toDir, ExtractorPattern... patterns) throws IOException;

    /**
     * Extract the given archive file to the given directory. This will extract all the files in the archive.
     * 
     * @param archive The archive file to be extracted.
     * @param toDir The directory to which the files are extracted to.
     * @throws IOException
     */
    void extract(File archive, File toDir) throws IOException;
}
